package com.example.demo8.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.demo8.mapper.ChatMapper;
import com.example.demo8.po.Chat;
import com.example.demo8.service.ChatService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 20556
 * @description 针对表【tb_chat】的数据库操作Service实现
 * @createDate 2024-05-02 16:44:06
 */
@Service
public class ChatServiceImpl extends ServiceImpl<ChatMapper, Chat>
        implements ChatService {

    @Override
    public List<Chat> listByFromAndTo(String from, String to) {
        return baseMapper.selectList(new LambdaQueryWrapper<Chat>()
                .or(wrapper -> wrapper.eq(Chat::getFromUser, from)
                        .eq(Chat::getToUser, to))
                .or(wrapper -> wrapper.eq(Chat::getFromUser, to)
                        .eq(Chat::getToUser, from))
        );
    }
}




